<template>
	<view class="yingdidetail">
		<headertop title="营地活动" :back1="back1"></headertop>
		<image src="https://39gongli.oss-cn-beijing.aliyuncs.com/static/image@2x (1).png" class="fengmian" mode="">
		</image>
		<view class="bottomcontent">
			<view class="contents">
				<view class="itemconten" v-for="(item,index) in list" :key="index" @click="gopage(item)">
					<image :src="item.image" class="leftimg" mode=""></image>
					<view class="texts">
						<view class="t1">
							{{item.title}}
						</view>
						<view class="miaoshu">
							{{item.detail}}
						</view>
						<view class="timeline">
							<image src="https://luying.hacuu.com/static/Frame@2x(27).png" mode=""></image>
							<span>{{timestampfun(item.createtime*1000)}}</span>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import headertop from '@/components/header.vue'
	import {
		reactive,
		ref,
	} from 'vue';
	import {
		activitylist
	} from "@/api/home.js"
	import {
		onPageScroll,
		onLoad
	} from "@dcloudio/uni-app";
	const currentNum = ref(0)
	const lastpage = ref(0)
	const list = ref([])
	const query = reactive({
		page: 1,
		limit: 10
	})
	const list6 = reactive([
		'https://luying.hacuu.com/static/Group 11407@2x.png',
		'https://luying.hacuu.com/static/Group 11407@2x.png',
		'https://luying.hacuu.com/static/Group 11407@2x.png',
	]);
	const back1 = ref('')
	onPageScroll((e) => {
		if (e.scrollTop > 100) {
			back1.value = 'rgba(0,0,0,0.32)'
		} else {
			back1.value = ''
		}
		if (lastpage.value > query.page) {
			query.page++
			activitylistinit()

		}
	})

	function gopage(item) {
		uni.navigateTo({
			url: '/sub_index/index/activedetail?id=' + item.id
		})
	}
	onLoad(() => {
		activitylistinit()
	})

	function timestampfun(time) {
		const date = new Date(time);
		const year = date.getFullYear();
		const month = String(date.getMonth() + 1).padStart(2, "0");
		const day = String(date.getDate()).padStart(2, "0");
		const hours = String(date.getHours()).padStart(2, "0");
		const minutes = String(date.getMinutes()).padStart(2, "0");
		const seconds = String(date.getSeconds()).padStart(2, "0");
		const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
		return formattedDate
	}
	// 营地活动
	async function activitylistinit() {
		const res = await activitylist(query)
		if (res.data.code == 1) {
			list.value.push(...res.data.data.list)
			lastpage.value = res.data.data.lastpage
		}
	}
</script>

<style lang="scss">
	page {
		background: #F7F8FA;
	}

	.yingdidetail {
		width: 100%;
		overflow: hidden;
		position: relative;

		.fengmian {
			width: 750rpx;
			height: 664rpx;
			position: absolute;
			z-index: -1;
		}

		.bottomcontent {
			width: 100%;
			background: #FFFFFF;
			border-radius: 36rpx 36rpx 0rpx 0rpx;
			margin-top: 630rpx;
			overflow: hidden;
			z-index: 999;

			.contents {
				width: 686rpx;
				margin: auto;
				overflow: hidden;

				.itemconten {
					width: 686rpx;
					height: 198rpx;
					background: #FFFFFF;
					box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0, 0, 0, 0.19);
					border-radius: 16rpx 16rpx 16rpx 16rpx;
					display: flex;
					align-items: center;
					margin-top: 28rpx;

					.texts {
						width: 404rpx;
						margin-left: 18rpx;
						overflow: hidden;

						.t1 {
							font-family: PingFang SC, PingFang SC;
							font-weight: bold;
							font-size: 26rpx;
							color: #1D2129;
						}

						.timeline {
							width: 100%;
							display: flex;
							align-items: center;
							margin-top: 18rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							font-size: 24rpx;
							color: #8D8D8D;

							image {
								width: 29rpx;
								height: 29rpx;
								border-radius: 50%;
								margin-right: 14rpx;
							}

						}

						.miaoshu {
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							font-size: 24rpx;
							color: #333333;
							margin-top: 8rpx;
							overflow: hidden;
							text-overflow: ellipsis;
							display: -webkit-box;
							-webkit-line-clamp: 2;
							-webkit-box-orient: vertical;
						}
					}

					.leftimg {
						width: 234rpx;
						height: 158rpx;
						border-radius: 10rpx;
						margin-left: 20rpx;
					}
				}
			}
		}




	}
</style>